#include <Arduino.h>
#include <IRremote.hpp>
#define IR_RECEIVE_PIN 12

// put function declarations here:
int led_pin = 3;
void blink();

void setup()
{
  // put your setup code here, to run once:
  pinMode(led_pin, OUTPUT);
  Serial.begin(9600);                                    // // Establish serial communication
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver
}

void loop()
{
  // put your main code here, to run repeatedly:
  if (IrReceiver.decode())
  {
    blink();
    Serial.print("LSM first:");
    Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);                  // Print "old" raw data
    Serial.print("MSB first:");
    Serial.println(bitreverse32Bit(IrReceiver.decodedIRData.decodedRawData), HEX); // MSB first
    IrReceiver.printIRResultShort(&Serial);                                        // Print complete received data in one line
    IrReceiver.printIRSendUsage(&Serial);                                          // Print the statement required to send this data
    IrReceiver.resume();                                                           // Enable receiving of the next value
  }
}

// put function definitions here:
void blink()
{
  digitalWrite(led_pin, HIGH);
  delay(100);
  digitalWrite(led_pin, LOW);
  delay(100);
}